class StoreTodo < ActiveRecord::Base
  self.table_name = 'todos'

  belongs_to :store

  scope :finished, -> { where(done: true) }
  scope :unfinished, -> { where(done: false) }
  scope :todo_by_ids, ->(ids) { where(id: ids) }

  def toggle!
    self.update!(done: !self.done)
  end

  def self.to_delete(ids)
    todo_by_ids(ids).delete_all
  end
end
